Test dynamic addition/removal.
authorMatthias Clasen <maclas@gmx.de>
Mon, 8 Mar 2004 00:08:11 +0000 (00:08 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 8 Mar 2004 00:08:11 +0000 (00:08 +0000)
Mon Mar  8 01:06:17 2004  Matthias Clasen  <maclas@gmx.de>

* tests/testentrycompletion.c: Test dynamic addition/removal.

Sun Mar  7 22:38:49 2004  Matthias Clasen  <maclas@gmx.de>

* gtk/gtkframe.c (gtk_frame_paint): Use ythickness, not
xthickness in the calculation of vertical dimensions.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkframe.c
tests/testentrycompletion.c

index bb0085f39e19b0c9f5f5f3040f7e76b7ca9872cf..1aa8b257b4d50eb12c42e194f2d7eb763d54ec9b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Mon Mar  8 01:06:17 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * tests/testentrycompletion.c: Test dynamic addition/removal. 
+
+Sun Mar  7 22:38:49 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkframe.c (gtk_frame_paint): Use ythickness, not 
+       xthickness in the calculation of vertical dimensions.
+
 Sun Mar  7 17:38:03 2004  Jonathan Blandford  <jrb@gnome.org>
 
        * gtk/gtkbutton.c (gtk_button_class_init): actually use
index bb0085f39e19b0c9f5f5f3040f7e76b7ca9872cf..1aa8b257b4d50eb12c42e194f2d7eb763d54ec9b 100644 (file)
@@ -1,3 +1,12 @@
+Mon Mar  8 01:06:17 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * tests/testentrycompletion.c: Test dynamic addition/removal. 
+
+Sun Mar  7 22:38:49 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkframe.c (gtk_frame_paint): Use ythickness, not 
+       xthickness in the calculation of vertical dimensions.
+
 Sun Mar  7 17:38:03 2004  Jonathan Blandford  <jrb@gnome.org>
 
        * gtk/gtkbutton.c (gtk_button_class_init): actually use
index bb0085f39e19b0c9f5f5f3040f7e76b7ca9872cf..1aa8b257b4d50eb12c42e194f2d7eb763d54ec9b 100644 (file)
@@ -1,3 +1,12 @@
+Mon Mar  8 01:06:17 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * tests/testentrycompletion.c: Test dynamic addition/removal. 
+
+Sun Mar  7 22:38:49 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkframe.c (gtk_frame_paint): Use ythickness, not 
+       xthickness in the calculation of vertical dimensions.
+
 Sun Mar  7 17:38:03 2004  Jonathan Blandford  <jrb@gnome.org>
 
        * gtk/gtkbutton.c (gtk_button_class_init): actually use
index bb0085f39e19b0c9f5f5f3040f7e76b7ca9872cf..1aa8b257b4d50eb12c42e194f2d7eb763d54ec9b 100644 (file)
@@ -1,3 +1,12 @@
+Mon Mar  8 01:06:17 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * tests/testentrycompletion.c: Test dynamic addition/removal. 
+
+Sun Mar  7 22:38:49 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkframe.c (gtk_frame_paint): Use ythickness, not 
+       xthickness in the calculation of vertical dimensions.
+
 Sun Mar  7 17:38:03 2004  Jonathan Blandford  <jrb@gnome.org>
 
        * gtk/gtkbutton.c (gtk_button_class_init): actually use
index bb0085f39e19b0c9f5f5f3040f7e76b7ca9872cf..1aa8b257b4d50eb12c42e194f2d7eb763d54ec9b 100644 (file)
@@ -1,3 +1,12 @@
+Mon Mar  8 01:06:17 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * tests/testentrycompletion.c: Test dynamic addition/removal. 
+
+Sun Mar  7 22:38:49 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkframe.c (gtk_frame_paint): Use ythickness, not 
+       xthickness in the calculation of vertical dimensions.
+
 Sun Mar  7 17:38:03 2004  Jonathan Blandford  <jrb@gnome.org>
 
        * gtk/gtkbutton.c (gtk_button_class_init): actually use
index ddb1c1fba27c2595fa168c5a9d68dcd5163c464f..eb02f9c8e28720ed764e0880b44ebe5a48a3e4cb 100644 (file)
@@ -502,7 +502,7 @@ gtk_frame_paint (GtkWidget    *widget,
       frame = GTK_FRAME (widget);
 
       x = frame->child_allocation.x - widget->style->xthickness;
-      y = frame->child_allocation.y - widget->style->ythickness;
+      y = frame->child_allocation.y; - widget->style->ythickness;
       width = frame->child_allocation.width + 2 * widget->style->xthickness;
       height =  frame->child_allocation.height + 2 * widget->style->ythickness;
 
@@ -520,7 +520,7 @@ gtk_frame_paint (GtkWidget    *widget,
          else
            xalign = 1 - frame->label_xalign;
 
-         height_extra = MAX (0, child_requisition.height - widget->style->xthickness);
+         height_extra = MAX (0, child_requisition.height - widget->style->ythickness);
          y -= height_extra * (1 - frame->label_yalign);
          height += height_extra * (1 - frame->label_yalign);
          
@@ -570,7 +570,7 @@ gtk_frame_size_request (GtkWidget      *widget,
 
       requisition->width = child_requisition.width + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
       requisition->height =
-       MAX (0, child_requisition.height - GTK_WIDGET (widget)->style->xthickness);
+       MAX (0, child_requisition.height - GTK_WIDGET (widget)->style->ythickness);
     }
   else
     {
index fdee669ea4e06bf69d8c89e9da7562d9b20cfd9a..7fcfb510ae3fc274a00b371e00e4c9876229c604 100644 (file)
@@ -1,5 +1,7 @@
 
 #include <config.h>
+#include <stdlib.h>
+#include <string.h>
 #include <gtk/gtk.h>
 
 /* Don't copy this bad example; inline RGB data is always a better
@@ -130,16 +132,32 @@ create_completion_model (void)
   return GTK_TREE_MODEL (store);
 }
 
-#if 0
 static gboolean
 match_func (GtkEntryCompletion *completion,
            const gchar        *key,
            GtkTreeIter        *iter,
            gpointer            user_data)
 {
-  return FALSE;
+  gchar *item = NULL;
+  GtkTreeModel *model;
+
+  gboolean ret = FALSE;
+
+  model = gtk_entry_completion_get_model (completion);
+
+  gtk_tree_model_get (model, iter, 1, &item, -1);
+
+  if (item != NULL)
+    {
+      g_print ("compare %s %s\n", key, item);
+      if (strncmp (key, item, strlen (key)) == 0)
+       ret = TRUE;
+
+      g_free (item);
+    }
+
+  return ret;
 }
-#endif
 
 static void
 activated_cb (GtkEntryCompletion *completion, 
@@ -149,6 +167,60 @@ activated_cb (GtkEntryCompletion *completion,
   g_print ("action activated: %d\n", index);
 }
 
+static gint timer_count = 0;
+
+static gchar *dynamic_completions[] = {
+  "GNOME",
+  "gnominious",
+  "Gnomonic projection",
+  "total",
+  "totally",
+  "toto",
+  "tottery",
+  "totterer",
+  "Totten trust",
+  "totipotent",
+  "totipotency",
+  "totemism",
+  "totem pole",
+  "Totara",
+  "totalizer",
+  "totalizator",
+  "totalitarianism",
+  "total parenteral nutrition",
+  "total hysterectomy",
+  "total eclipse",
+  "Totipresence",
+  "Totipalmi",
+  "zombie"
+};
+
+static gint
+animation_timer (GtkEntryCompletion *completion)
+{
+  GtkTreeIter iter;
+  gint n_completions = G_N_ELEMENTS (dynamic_completions);
+  gint n;
+
+  GtkListStore *store = GTK_LIST_STORE (gtk_entry_completion_get_model (completion));
+
+  if ((timer_count / n_completions) % 2 == 0)
+    {
+      n = timer_count % n_completions;
+      gtk_list_store_append (store, &iter);
+      gtk_list_store_set (store, &iter, 0, dynamic_completions[n], -1);
+      
+    }
+  else
+    {
+      gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
+      gtk_list_store_remove (store, &iter);
+    }
+  
+  timer_count++;
+  return TRUE;
+}
+
 int 
 main (int argc, char *argv[])
 {
@@ -215,22 +287,41 @@ main (int argc, char *argv[])
   gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion), cell, FALSE);
   gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (completion), cell, 
                                  "pixbuf", 0, NULL); 
-  /* Use model column 1 as the text column */
-  gtk_entry_completion_set_text_column (completion, 1);
 
-#if 0
   cell = gtk_cell_renderer_text_new ();
   gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion), cell, FALSE);
   gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (completion), cell, 
                                  "text", 1, NULL); 
   
   gtk_entry_completion_set_match_func (completion, match_func, NULL, NULL);
-#endif
 
   gtk_entry_completion_insert_action_text (completion, 100, "action!");
   gtk_entry_completion_insert_action_text (completion, 101, "'nother action!");
   g_signal_connect (completion, "action_activated", G_CALLBACK (activated_cb), 0);
 
+  /* Create our third entry */
+  entry = gtk_entry_new ();
+  gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
+
+  /* Create the completion object */
+  completion = gtk_entry_completion_new ();
+  
+  /* Assign the completion to the entry */
+  gtk_entry_set_completion (GTK_ENTRY (entry), completion);
+  g_object_unref (completion);
+  
+  /* Create a tree model and use it as the completion model */
+  completion_model = tgtk_list_store_new (1, G_TYPE_STRING);
+
+  gtk_entry_completion_set_model (completion, completion_model);
+  g_object_unref (completion_model);
+
+  /* Use model column 0 as the text column */
+  gtk_entry_completion_set_text_column (completion, 0);
+
+  /* Fill the completion dynamically */
+  g_timeout_add (1000, (GSourceFunc) animation_timer, completion);
+
   gtk_widget_show_all (window);
 
   gtk_main ();